package com.bupt.kgplatform.service.impl;

import com.alibaba.fastjson.JSONObject;

import com.bupt.kgplatform.entity.pojo.OperateLog;
import com.bupt.kgplatform.entity.pojo.SearchLogInfo;
import com.bupt.kgplatform.mapper.BackstageMapper;
import com.bupt.kgplatform.service.BackstageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * ClassName:BackStageServiceImpl
 * Package:com.example.blackjavaweb.service.impl
 * Description:
 *
 * @Author QIQI_1999
 * @Creat 2023/9/18 16:10
 * @Version 1.0
 */
@Service
public class BackstageServiceImpl implements BackstageService {
    @Autowired
    private BackstageMapper backstageMapper;
    @Override
    public Object searchLog(SearchLogInfo searchLogInfo) {
        List<OperateLog> operateLogList = backstageMapper.getLogInfo((searchLogInfo.getPage() - 1) * searchLogInfo.getPageSize(),searchLogInfo.getPageSize());
        Object operateLogListJson = JSONObject.toJSON(operateLogList);
        Integer sum = backstageMapper.getLogSum();
        JSONObject mergedObject = new JSONObject();

        mergedObject.put("infoList", operateLogListJson);
        mergedObject.put("sum", sum);
        return mergedObject;
    }
}
